﻿
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <form action="/User/PostForm" method="post">
        登录名:<input type="text" name="LoginName" />
        <input type="submit" name="name" value="提交" />
    </form>
    <form action="/User/UploadFile" method="post" enctype="multipart/form-data">
        <input type="file" name="files" value="" multiple />
        <button>上传</button>
    </form>

    <form action="/User/UploadFiles" method="post" enctype="multipart/form-data">
        <input type="file" name="files" value="" multiple />
        <button>上传</button>
    </form>

    <!-- 异步上传文件 -->
    <form id="formable" enctype="multipart/form-data">
        <input type="file" name="files" value="" multiple />
        <input type="button" name="btnok" value="提交" />
    </form>
    <script src="../Scripts/jquery-3.3.1.js"></script>
    <script>
        $("#btnok").click(function () {
            var formdata = new FormData(document.getElementById("formable"));
            $.ajax({
                url: "/User/UploadFiles",
                data: formdata,
                type: "post",
                dataType: "json",
                processData: false,
                contentType: false,
                success: function (data) { alert(data);}
            })
        });
    </script>
</body>
</html>